import java.util.ArrayList;
import java.util.List;

public class RestoreIpAddresses {

    public static void main(String[] args) {

        StringBuffer stringBuffer = new StringBuffer("172162541");
        RestoreIpAddresses restoreIpAddresses = new RestoreIpAddresses();
        System.out.println(restoreIpAddresses.restoreIpAddresses("00000"));
    }

    public List<String> ans = new ArrayList<>();

    public List<String> restoreIpAddresses(String s) {
        if (s.length() <= 3) return new ArrayList<>();
        StringBuffer sb = new StringBuffer(s);
        process(sb, 0, 0);
        return ans;
    }

    public void process(StringBuffer sb, int i, int n) {
        if (i >= sb.length() - 1 || n == 3) {
            String[] split = sb.toString().split("\\.");
            if (split.length != 4) return;
            long i1 = Long.parseLong(split[3]);
            if (i1 >= 0 && i1 <= 255 && !(split[3].charAt(0) == '0' && split[3].length() != 1)) ans.add(sb.toString());
            return;
        }

        char c = sb.charAt(i);
        if (c == '0') {
            sb.insert(i + 1, ".");
            process(sb, i + 2, n + 1);
            sb.delete(i + 1, i + 2);
        } else {
            sb.insert(i + 1, ".");
            process(sb, i + 2, n + 1);
            sb.delete(i + 1, i + 2);
            sb.insert(i + 2, ".");
            process(sb, i + 3, n + 1);
            sb.delete(i + 2, i + 3);
            if ((c == '1' && i + 2 < sb.length()) || (c == '2' && (i + 2 < sb.length() &&
                    ((sb.charAt(i + 1) == '5'
                            && sb.charAt(i + 2) <= '5') || (sb.charAt(i + 1) < '5'))))) {
                sb.insert(i + 3, ".");
                process(sb, i + 4, n + 1);
                sb.delete(i + 3, i + 4);
            }
        }
    }
}
